
use WorkfloDev
go

set xact_abort on
begin transaction

insert into [Language] (Id, ISOName) values (1, 'en-GB')

insert into CustomerStatus (Id, Name, Description) values (1, 'Prospect', 'Prospect')
insert into CustomerStatus (Id, Name, Description) values (2, 'Active', 'Active')
insert into CustomerStatus (Id, Name, Description) values (3, 'Closed', 'Closed')

insert into Customer (Name, CustomerStatusId) values ('Internal', 2)

insert into [Role] (Rolename, ApplicationName) values ('Administrators', 'Workflo')

insert into [User] (Username, Displayname, Password, EmailAddress, IsApproved, ProviderName, PasswordQuestion, PasswordAnswer, Comment, IsLockedOut, CreationDate, LastLoginDate, LastActivityDate, LastPasswordChangedDate, LastLockoutDate, ApplicationName) 
    values ('administrator', 'Administrator', 'jsyWBgef4klL3XqscQh6/7Fc9mM3I501m4fJGUXYcP6KBsVEsgSa3rmx1SCk/7hfGM0FMU87FqrYdDmlGwPIWA==', 'admin@genrsis.com', 1, 'AspNetSqlMembershipProvider', 'Are you an admin?', 'Yes', '', 0, getdate(), null, null, null, null, '/')
-- Secrets are precious things!

insert into UserProfile (UserId, LanguageId) select Id, 1 from [user]

insert into UserRole (UserId, RoleId) select Id, 1 from [user]

insert into UserCustomer (UserId, CustomerId) select Id, 1 from [user]

insert into ProjectStatus (Id, Name, Description) values (1, 'Prospect', 'Potential future project')
insert into ProjectStatus (Id, Name, Description) values (2, 'Active', 'Current active project')
insert into ProjectStatus (Id, Name, Description) values (3, 'Completed', 'Completed project')
insert into ProjectStatus (Id, Name, Description) values (4, 'Cancelled', 'Cancelled project')

insert into Project (ParentProjectId, ProjectName, Code, CreatedByUserId, ProjectStatusId) values (null, 'Sample project', 'Sample', 1, 1)

insert into ProjectCustomer (ProjectId, CustomerId) values (1, 1)

INSERT INTO Workflow (Name, CreatedByUserId) values ('Task Workflow', 1)

insert into WorkItemStatus (Id, Name, Description, EstimateApplicable) values (1, 'Approval', 'Approval', 0)
insert into WorkItemStatus (Id, Name, Description, EstimateApplicable) values (2, 'In Progress', 'In Progress', 1)
insert into WorkItemStatus (Id, Name, Description, EstimateApplicable) values (3, 'Complete', 'Complete', 0)
insert into WorkItemStatus (Id, Name, Description, EstimateApplicable) values (4, 'Closed', 'Closed', 0)

insert into WorkItemStatusApplicableUser (WorkItemStatusId, UserId) select Id, 1 from WorkItemStatus

insert into WorkItemStatusTransitionType (Id, Name, Description) values (1, 'Advance', 'Advance')
insert into WorkItemStatusTransitionType (Id, Name, Description) values (2, 'Revert', 'Revert')
insert into WorkItemStatusTransitionType (Id, Name, Description) values (3, 'Veto', 'Veto')

insert into WorkItemStatusTransition (WorkflowId, SequenceId, FromWorkItemStatusId, WorkItemStatusTransitionTypeId, ToWorkItemStatusId) values (1, 1, 1, 1, 2)
insert into WorkItemStatusTransition (WorkflowId, SequenceId, FromWorkItemStatusId, WorkItemStatusTransitionTypeId, ToWorkItemStatusId) values (1, 1, 1, 3, 4)
insert into WorkItemStatusTransition (WorkflowId, SequenceId, FromWorkItemStatusId, WorkItemStatusTransitionTypeId, ToWorkItemStatusId) values (1, 1, 2, 1, 3)
insert into WorkItemStatusTransition (WorkflowId, SequenceId, FromWorkItemStatusId, WorkItemStatusTransitionTypeId, ToWorkItemStatusId) values (1, 1, 2, 2, 1)
insert into WorkItemStatusTransition (WorkflowId, SequenceId, FromWorkItemStatusId, WorkItemStatusTransitionTypeId, ToWorkItemStatusId) values (1, 1, 2, 3, 3)

insert into WorkItemType (Id, Name, Description, WorkflowId) values (1, 'Task', 'Non-product-specific task that does not require development', 1)

insert into WorkItem (Title, WorkItemTypeId, Opened, Closed, Description, CreatedByUserId, AssignedToUserId, WorkItemStatusId, ProjectId)
    values ('Welcome to Workflo!', 1, getdate(), null, 'Welcome to Workflo! This is the example first case.', 1, 1, 1, 1)

insert into WorkItemHistoryType (Id, Name, Description) values (1, 'Created', 'Created')
insert into WorkItemHistoryType (Id, Name, Description) values (2, 'Updated', 'Updated')
insert into WorkItemHistoryType (Id, Name, Description) values (3, 'Closed', 'Closed')

insert into WorkItemHistory (WorkItemId, UserId, WorkItemHistoryTypeId, Added, ChangeSummary, Info) values (1, 1, 1, getdate(), null, null)

commit

go
